package com.dumas.controller;

import com.dumas.utils.ApiUtilImp;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class GetApiController {

    @Autowired
    private ApiUtilImp apiUtilImp;

    //获取轮播图
    @RequestMapping(value = "/banner")
    public String getBanner(){
        return apiUtilImp.apiGet("banner");
    }

    //获取推荐歌单
    @RequestMapping(value = "/personalized")
    public String getPersonalizedPlaylist(){
        return apiUtilImp.apiGet("/personalized?limit=10");
    }

    //获取最新歌曲
    @RequestMapping(value = "/personalized/newsong/{limit}")
    public String getPersonalizedNewsong(@PathVariable String limit){
        return apiUtilImp.apiGet("personalized/newsong?limit="+limit);
    }

    //获取推荐MV
    @RequestMapping(value = "/personalized/mv")
    public String getPersonalizedMv(){
        return apiUtilImp.apiGet("personalized/mv");
    }

    //获取歌曲播放地址
    @RequestMapping(value = "/song/url/{id}")
    public String getMusicUrl(@PathVariable String id){
        return apiUtilImp.apiGet("song/url?id="+id);
    }

    //获取精品歌单
    @RequestMapping(value = "/top/playlist/highquality/{tag}")
    public String getTopPlaylist(@PathVariable String tag){
        return apiUtilImp.apiGet("/top/playlist/highquality?limit=1&cat="+tag);
    }

    //获取歌单列表
    @RequestMapping(value = "/top/playlist/{tag}/{offset}")
    public String getPalylist(@PathVariable String tag, @PathVariable String offset){
        return apiUtilImp.apiGet("/top/playlist?limit=10&cat="+tag+"&offset="+offset);
    }

    //获取Mv列表
    @RequestMapping(value = "/mv/all/{offset}/{area}/{order}/{type}")
    public String getMvs(@PathVariable String offset, @PathVariable String area, @PathVariable String order, @PathVariable String type){
        return apiUtilImp.apiGet("mv/all?limit=8&offset="+offset+"&area="+area+"&order="+order+"&type="+type);
    }

    //获取查询
    @RequestMapping(value = "/cloudsearch/{keywords}/{offset}/{type}")
    public String cloudsearch(@PathVariable String keywords, @PathVariable String offset, @PathVariable String type){
        return apiUtilImp.apiGet("cloudsearch?keywords="+keywords+"&limit=10&offset="+offset+"&type="+type);
    }

    //获取歌单详情
    @RequestMapping(value = "/playlist/detail/{id}")
    public String getPlaylistDetail(@PathVariable String id){
        return apiUtilImp.apiGet("playlist/detail?id="+id);
    }

    //获取歌单评论
    @RequestMapping(value = "/comment/playlist/{id}/{offset}")
    public String getPlaylistComments(@PathVariable String id, @PathVariable String offset){
        return apiUtilImp.apiGet("comment/playlist?id="+id+"&limit=10&offset="+offset);
    }

    //获取MV播放地址
    @RequestMapping(value = "/mv/url/{id}")
    public String getMvUrl(@PathVariable String id){
        return apiUtilImp.apiGet("mv/url?id="+id);
    }

    //获取MV详情
    @RequestMapping(value = "/mv/detail/{id}")
    public String getMvDetail(@PathVariable String id){
        return apiUtilImp.apiGet("mv/detail?mvid="+id);
    }

    //获取歌手头像
//    @RequestMapping(value = "/artist/desc/{id}")
//    public String getArtistIcon(@PathVariable String id){
//        return apiUtilImp.apiGet("/artist/mv?id="+id);
//    }

    //获取MV评论
    @RequestMapping(value = "/comment/mv/{id}/{offset}")
    public String getMvComment(@PathVariable String id, @PathVariable String offset){
        return apiUtilImp.apiGet("comment/mv?limit=10&id="+id+"&offset="+offset);
    }

    //获取相关MV
    @RequestMapping(value = "/simi/mv/{id}")
    public String getSimiMvUrl(@PathVariable String id){
        return apiUtilImp.apiGet("simi/mv?mvid="+id);
    }

    //用户登录
    @RequestMapping(value = "/login/{email}/{password}")
    public String login(@PathVariable String email, @PathVariable String password){
        return apiUtilImp.apiGet("/login?email="+email+"&password="+password);
    }

    //获取用户信息 , 歌单，收藏，mv数量
    @RequestMapping(value = "/user/subcount/{cookie}")
    public String getUserSubcount(@PathVariable String cookie){
        return apiUtilImp.apiGet("/user/subcount?cookie="+cookie);
    }

    //查看登录状态
    @RequestMapping(value = "/login/status/{cookie}")
    public String getLoginStatus(@PathVariable String cookie){
        return apiUtilImp.apiGet("/login/status?cookie="+cookie);
    }

    //获取用户详情
    @RequestMapping(value = "/user/detail/{uid}/{cookie}")
    public String getUserDetail( @PathVariable String uid, @PathVariable String cookie){
        return apiUtilImp.apiGet("/user/detail?uid="+uid+"&cookie="+cookie);
    }

    //获取用户歌单
    @RequestMapping(value = "/user/playlist/{uid}/{cookie}")
    public String getUserPlaylist( @PathVariable String uid, @PathVariable String cookie){
        return apiUtilImp.apiGet("/user/playlist?uid="+uid+"&cookie="+cookie);
    }
}
